class Solution
{
public:
    bool findWhetherExistsPath(int n, vector<vector<int>> &graph, int start, int target)
    {
        unordered_map<int, vector<int>> adjTable;
        for (auto &edge : graph)
        {
            adjTable[edge[0]].push_back(edge[1]);
        }
        queue<int> q;
        q.push(start);
        unordered_set<int> visited;
        visited.insert(start);
        while (!q.empty())
        {
            int node = q.front();
            q.pop();
            for (int adjNode : adjTable[node])
            {
                if (adjNode == target)
                {
                    return true;
                }
                if (!visited.count(adjNode))
                {
                    q.push(adjNode);
                    visited.insert(adjNode);
                }
            }
        }
        return false;
    }
};